package com.yj.web.dao.mapper;

import com.yj.web.dao.po.admin.CustomerService;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by yanlinyang on 2017/7/24.
 */
@Component
public interface CustomerServiceMapper {
    @Select("select * from cus_user_contact where deleted_flag = 'N' order by created_at desc limit #{size} offset #{offset}")
    public List<CustomerService> listCustomerService(@Param("offset") int offset, @Param("size") int size);

    @Select("select count(*) from cus_user_contact where deleted_flag = 'N'")
    public int countCustomerService();

    @Select("select * from cus_user_contact where id = #{id} and status = 0")
    public CustomerService findCustomerServiceById(@Param("id") String id);

    @Select("select * from cus_user_contact where id = #{id} and status = 1")
    public CustomerService findCustomerServiceByIdFinished(@Param("id") String id);

    @Update("update cus_user_contact set update_id=#{service.update_id}, updated_at=now(), completed_at=now(), solution=#{service.solution}, " +
            " processor_id=#{service.processor_id}, type=#{service.type}, status=1 where id = #{service.id} and deleted_flag = 'N' and status=0")
    public boolean updateCustomerService(@Param("service") CustomerService service);
}
